package com.sun.alen.mapper;

import com.sun.alen.entity.MainClass;
import org.apache.ibatis.annotations.*;

import java.util.Collection;
import java.util.List;

@Mapper
public interface MainClassMapper {
    @Insert("INSERT INTO mainClass (className, classNumber, teacherId,professionId) " +
            "VALUES (#{className}, #{classNumber}, #{teacherId},#{professionId})")
    boolean add(MainClass mainClass);

    @Update("UPDATE mainClass SET className=#{className}, classNumber=#{classNumber}, teacherId=#{teacherId} ,professionId=#{professionId} " +
            "WHERE classId=#{classId}")
    boolean update(MainClass mainClass);

    @Delete("DELETE FROM mainClass WHERE classId=#{id}")
    boolean delete(String id);

    @Select("select * from mainClass limit #{start},#{pageSize}")
    List<MainClass> list(Integer start, Integer pageSize);

    @Select("select count(*) from mainClass")
    long count();

    @Select("select * from mainClass where className like #{input} limit #{start},#{pageSize}")
    List<MainClass> searchByName(String input, Integer start, Integer pageSize);

    @Select("select count(*) from mainClass where className like #{input}")
    long countByName(String input);

    @Select("select * from mainClass where professionId =#{id} ")
    List<MainClass> searchByProfession(int id);

    @Select("select * from mainClass where teacherId =#{teacherId}")
    List<MainClass> searchByTeacher(int teacherId);

    @Select("select * from mainClass where className like #{input}")
    List<MainClass> searchIdByName(String input);

    @Select("select * from mainClass")
    List<MainClass> all();

    @Select("select * from mainClass where teacherId = #{id}")
    List<MainClass> getMainClassByTea(String id);

    /**
     * 老师自己所管理的班级
     */
    @Select("select * from mainclass where teacherId = #{input} limit #{start},#{pageSize}")
    List<MainClass> listByTeacherId(Integer input, Integer start, Integer pageSize);

    @Select("select count(*) from mainclass where teacherId = #{input} ")
    long countByTeacherId(Integer input);

    @Select("select * from mainclass where className like #{input} and teacherId = #{teacherId} limit #{start},#{pageSize}")
    List<MainClass> searchByClassName(String input, Integer teacherId, Integer start, Integer pageSize);

    @Select("select count(*) from mainclass where className like #{input} and teacherId = #{teacherId}")
    long countByClassName(String input, Integer teacherId);


    @Select("select * from mainclass where className like #{input} and teacherId = #{teacherId}")
    List<MainClass> searchByClassName1(String input, Integer teacherId);
}
